home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / cursesw.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-06-22  |  44.0 KB  |  1,437 lines

  1. // * This makes emacs happy -*-Mode: C++;-*-
  2. /****************************************************************************
  3.  * Copyright (c) 1998-2004,2005 Free Software Foundation, Inc.              *
  4.  *                                                                          *
  5.  * Permission is hereby granted, free of charge, to any person obtaining a  *
  6.  * copy of this software and associated documentation files (the            *
  7.  * "Software"), to deal in the Software without restriction, including      *
  8.  * without limitation the rights to use, copy, modify, merge, publish,      *
  9.  * distribute, distribute with modifications, sublicense, and/or sell       *
  10.  * copies of the Software, and to permit persons to whom the Software is    *
  11.  * furnished to do so, subject to the following conditions:                 *
  12.  *                                                                          *
  13.  * The above copyright notice and this permission notice shall be included  *
  14.  * in all copies or substantial portions of the Software.                   *
  15.  *                                                                          *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
  17.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
  18.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
  19.  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
  20.  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
  21.  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
  22.  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
  23.  *                                                                          *
  24.  * Except as contained in this notice, the name(s) of the above copyright   *
  25.  * holders shall not be used in advertising or otherwise to promote the     *
  26.  * sale, use or other dealings in this Software without prior written       *
  27.  * authorization.                                                           *
  28.  ****************************************************************************/
  29.  
  30. #ifndef NCURSES_CURSESW_H_incl
  31. #define NCURSES_CURSESW_H_incl 1
  32.  
  33. // $Id: cursesw.h,v 1.38 2005/07/23 20:51:39 tom Exp $
  34.  
  35. #include <stdarg.h>
  36. #include <stdio.h>
  37.  
  38. #include <etip.h>
  39.  
  40. #if HAVE_STRSTREAM_H && (USE_STRSTREAM_VSCAN||USE_STRSTREAM_VSCAN_CAST)
  41. #include <strstream.h>
  42. #endif
  43.  
  44. extern "C" {
  45. #  include   <curses.h>
  46. }
  47.  
  48. /* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
  49.    Undefine it here, because NCursesWindow uses lines as a method.  */
  50. #undef lines
  51.  
  52. /* "Convert" macros to inlines. We'll define it as another symbol to avoid
  53.  * conflict with library symbols.
  54.  */
  55. #undef UNDEF
  56. #define UNDEF(name) CUR_ ##name
  57.  
  58. #ifdef addch
  59. inline int UNDEF(addch)(chtype ch)  { return addch(ch); }
  60. #undef addch
  61. #define addch UNDEF(addch)
  62. #endif
  63.  
  64. #ifdef echochar
  65. inline int UNDEF(echochar)(chtype ch)  { return echochar(ch); }
  66. #undef echochar
  67. #define echochar UNDEF(echochar)
  68. #endif
  69.  
  70. #ifdef insdelln
  71. inline int UNDEF(insdelln)(int n)  { return insdelln(n); }
  72. #undef insdelln
  73. #define insdelln UNDEF(insdelln)
  74. #endif
  75.  
  76. #ifdef addstr
  77. inline int UNDEF(addstr)(const char * str)  { return addstr(str); }
  78. #undef addstr
  79. #define addstr UNDEF(addstr)
  80. #endif
  81.  
  82. #ifdef attron
  83. inline int UNDEF(attron)(chtype at) { return attron(at); }
  84. #undef attron
  85. #define attron UNDEF(attron)
  86. #endif
  87.  
  88. #ifdef attroff
  89. inline int UNDEF(attroff)(chtype at) { return attroff(at); }
  90. #undef attroff
  91. #define attroff UNDEF(attroff)
  92. #endif
  93.  
  94. #ifdef attrset
  95. inline chtype UNDEF(attrset)(chtype at) { return attrset(at); }
  96. #undef attrset
  97. #define attrset UNDEF(attrset)
  98. #endif
  99.  
  100. #ifdef color_set
  101. inline chtype UNDEF(color_set)(short p, void* opts) { return color_set(p, opts); }
  102. #undef color_set
  103. #define color_set UNDEF(color_set)
  104. #endif
  105.  
  106. #ifdef border
  107. inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
  108. { return border(ls, rs, ts, bs, tl, tr, bl, br); }
  109. #undef border
  110. #define border UNDEF(border)
  111. #endif
  112.  
  113. #ifdef box
  114. inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); }
  115. #undef box
  116. #define box UNDEF(box)
  117. #endif
  118.  
  119. #ifdef mvwhline
  120. inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) {
  121.   return mvwhline(win, y, x, c, n); }
  122. #undef mvwhline
  123. #define mvwhline UNDEF(mvwhline)
  124. #endif
  125.  
  126. #ifdef mvwvline
  127. inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) {
  128.   return mvwvline(win, y, x, c, n); }
  129. #undef mvwvline
  130. #define mvwvline UNDEF(mvwvline)
  131. #endif
  132.  
  133. #ifdef clear
  134. inline int UNDEF(clear)()  { return clear(); }
  135. #undef clear
  136. #define clear UNDEF(clear)
  137. #endif
  138.  
  139. #ifdef clearok
  140. inline int UNDEF(clearok)(WINDOW* win, bool bf)  { return clearok(win, bf); }
  141. #undef clearok
  142. #define clearok UNDEF(clearok)
  143. #else
  144. extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool);
  145. #endif
  146.  
  147. #ifdef clrtobot
  148. inline int UNDEF(clrtobot)()  { return clrtobot(); }
  149. #undef clrtobot
  150. #define clrtobot UNDEF(clrtobot)
  151. #endif
  152.  
  153. #ifdef clrtoeol
  154. inline int UNDEF(clrtoeol)()  { return clrtoeol(); }
  155. #undef clrtoeol
  156. #define clrtoeol UNDEF(clrtoeol)
  157. #endif
  158.  
  159. #ifdef delch
  160. inline int UNDEF(delch)()  { return delch(); }
  161. #undef delch
  162. #define delch UNDEF(delch)
  163. #endif
  164.  
  165. #ifdef deleteln
  166. inline int UNDEF(deleteln)()  { return deleteln(); }
  167. #undef deleteln
  168. #define deleteln UNDEF(deleteln)
  169. #endif
  170.  
  171. #ifdef erase
  172. inline int UNDEF(erase)()  { return erase(); }
  173. #undef erase
  174. #define erase UNDEF(erase)
  175. #endif
  176.  
  177. #ifdef flushok
  178. inline int UNDEF(flushok)(WINDOW* _win, bool _bf)  {
  179.   return flushok(_win, _bf); }
  180. #undef flushok
  181. #define flushok UNDEF(flushok)
  182. #else
  183. #define _no_flushok
  184. #endif
  185.  
  186. #ifdef getch
  187. inline int UNDEF(getch)()  { return getch(); }
  188. #undef getch
  189. #define getch UNDEF(getch)
  190. #endif
  191.  
  192. #ifdef getstr
  193. inline int UNDEF(getstr)(char *_str)  { return getstr(_str); }
  194. #undef getstr
  195. #define getstr UNDEF(getstr)
  196. #endif
  197.  
  198. #ifdef instr
  199. inline int UNDEF(instr)(char *_str)  { return instr(_str); }
  200. #undef instr
  201. #define instr UNDEF(instr)
  202. #endif
  203.  
  204. #ifdef innstr
  205. inline int UNDEF(innstr)(char *_str, int n)  { return innstr(_str, n); }
  206. #undef innstr
  207. #define innstr UNDEF(innstr)
  208. #endif
  209.  
  210. #ifdef mvwinnstr
  211. inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) {
  212.   return mvwinnstr(win, y, x, _str, n); }
  213. #undef mvwinnstr
  214. #define mvwinnstr UNDEF(mvwinnstr)
  215. #endif
  216.  
  217. #ifdef mvinnstr
  218. inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) {
  219.   return mvinnstr(y, x, _str, n); }
  220. #undef mvinnstr
  221. #define mvinnstr UNDEF(mvinnstr)
  222. #endif
  223.  
  224. #ifdef winsstr
  225. inline int UNDEF(winsstr)(WINDOW *w, const char *_str)  {
  226.   return winsstr(w, _str); }
  227. #undef winsstr
  228. #define winsstr UNDEF(winsstr)
  229. #endif
  230.  
  231. #ifdef mvwinsstr
  232. inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x,  const char *_str)  {
  233.   return mvwinsstr(w, y, x, _str); }
  234. #undef mvwinsstr
  235. #define mvwinsstr UNDEF(mvwinsstr)
  236. #endif
  237.  
  238. #ifdef insstr
  239. inline int UNDEF(insstr)(const char *_str)  {
  240.   return insstr(_str); }
  241. #undef insstr
  242. #define insstr UNDEF(insstr)
  243. #endif
  244.  
  245. #ifdef mvinsstr
  246. inline int UNDEF(mvinsstr)(int y, int x, const char *_str)  {
  247.   return mvinsstr(y, x, _str); }
  248. #undef mvinsstr
  249. #define mvinsstr UNDEF(mvinsstr)
  250. #endif
  251.  
  252. #ifdef insnstr
  253. inline int UNDEF(insnstr)(const char *_str, int n)  {
  254.   return insnstr(_str, n); }
  255. #undef insnstr
  256. #define insnstr UNDEF(insnstr)
  257. #endif
  258.  
  259. #ifdef mvwinsnstr
  260. inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) {
  261.   return mvwinsnstr(w, y, x, _str, n); }
  262. #undef mvwinsnstr
  263. #define mvwinsnstr UNDEF(mvwinsnstr)
  264. #endif
  265.  
  266. #ifdef mvinsnstr
  267. inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) {
  268.   return mvinsnstr(y, x, _str, n); }
  269. #undef mvinsnstr
  270. #define mvinsnstr UNDEF(mvinsnstr)
  271. #endif
  272.  
  273. #ifdef getnstr
  274. inline int UNDEF(getnstr)(char *_str, int n)  { return getnstr(_str, n); }
  275. #undef getnstr
  276. #define getnstr UNDEF(getnstr)
  277. #endif
  278.  
  279. #ifdef getyx
  280. inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) {
  281.   getyx(win, y, x); }
  282. #undef getyx
  283. #define getyx UNDEF(getyx)
  284. #endif
  285.  
  286. #ifdef getbegyx
  287. inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); }
  288. #undef getbegyx
  289. #define getbegyx UNDEF(getbegyx)
  290. #endif
  291.  
  292. #ifdef getmaxyx
  293. inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); }
  294. #undef getmaxyx
  295. #define getmaxyx UNDEF(getmaxyx)
  296. #endif
  297.  
  298. #ifdef hline
  299. inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); }
  300. #undef hline
  301. #define hline UNDEF(hline)
  302. #endif
  303.  
  304. #ifdef inch
  305. inline chtype UNDEF(inch)()  { return inch(); }
  306. #undef inch
  307. #define inch UNDEF(inch)
  308. #endif
  309.  
  310. #ifdef insch
  311. inline int UNDEF(insch)(chtype c)  { return insch(c); }
  312. #undef insch
  313. #define insch UNDEF(insch)
  314. #endif
  315.  
  316. #ifdef insertln
  317. inline int UNDEF(insertln)()  { return insertln(); }
  318. #undef insertln
  319. #define insertln UNDEF(insertln)
  320. #endif
  321.  
  322. #ifdef leaveok
  323. inline int UNDEF(leaveok)(WINDOW* win, bool bf)  { return leaveok(win, bf); }
  324. #undef leaveok
  325. #define leaveok UNDEF(leaveok)
  326. #else
  327. extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf);
  328. #endif
  329.  
  330. #ifdef move
  331. inline int UNDEF(move)(int x, int y)  { return move(x, y); }
  332. #undef move
  333. #define move UNDEF(move)
  334. #endif
  335.  
  336. #ifdef refresh
  337. inline int UNDEF(refresh)()  { return refresh(); }
  338. #undef refresh
  339. #define refresh UNDEF(refresh)
  340. #endif
  341.  
  342. #ifdef redrawwin
  343. inline int UNDEF(redrawwin)(WINDOW *win)  { return redrawwin(win); }
  344. #undef redrawwin
  345. #define redrawwin UNDEF(redrawwin)
  346. #endif
  347.  
  348. #ifdef scrl
  349. inline int UNDEF(scrl)(int l) { return scrl(l); }
  350. #undef scrl
  351. #define scrl UNDEF(scrl)
  352. #endif
  353.  
  354. #ifdef scroll
  355. inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); }
  356. #undef scroll
  357. #define scroll UNDEF(scroll)
  358. #endif
  359.  
  360. #ifdef scrollok
  361. inline int UNDEF(scrollok)(WINDOW* win, bool bf)  { return scrollok(win, bf); }
  362. #undef scrollok
  363. #define scrollok UNDEF(scrollok)
  364. #else
  365. #if    defined(__NCURSES_H)
  366. extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool);
  367. #else
  368. extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char);
  369. #endif
  370. #endif
  371.  
  372. #ifdef setscrreg
  373. inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); }
  374. #undef setscrreg
  375. #define setscrreg UNDEF(setscrreg)
  376. #endif
  377.  
  378. #ifdef standend
  379. inline int UNDEF(standend)()  { return standend(); }
  380. #undef standend
  381. #define standend UNDEF(standend)
  382. #endif
  383.  
  384. #ifdef standout
  385. inline int UNDEF(standout)()  { return standout(); }
  386. #undef standout
  387. #define standout UNDEF(standout)
  388. #endif
  389.  
  390. #ifdef subpad
  391. inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x)
  392. { return derwin(p, l, c, y, x); }
  393. #undef subpad
  394. #define subpad UNDEF(subpad)
  395. #endif
  396.  
  397. #ifdef timeout
  398. inline void UNDEF(timeout)(int delay) { timeout(delay); }
  399. #undef timeout
  400. #define timeout UNDEF(timeout)
  401. #endif
  402.  
  403. #ifdef touchline
  404. inline int UNDEF(touchline)(WINDOW *win, int s, int c)
  405. { return touchline(win, s, c); }
  406. #undef touchline
  407. #define touchline UNDEF(touchline)
  408. #endif
  409.  
  410. #ifdef touchwin
  411. inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); }
  412. #undef touchwin
  413. #define touchwin UNDEF(touchwin)
  414. #endif
  415.  
  416. #ifdef untouchwin
  417. inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); }
  418. #undef untouchwin
  419. #define untouchwin UNDEF(untouchwin)
  420. #endif
  421.  
  422. #ifdef vline
  423. inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); }
  424. #undef vline
  425. #define vline UNDEF(vline)
  426. #endif
  427.  
  428. #ifdef waddstr
  429. inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); }
  430. #undef waddstr
  431. #define waddstr UNDEF(waddstr)
  432. #endif
  433.  
  434. #ifdef waddchstr
  435. inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); }
  436. #undef waddchstr
  437. #define waddchstr UNDEF(waddchstr)
  438. #endif
  439.  
  440. #ifdef wstandend
  441. inline int UNDEF(wstandend)(WINDOW *win)  { return wstandend(win); }
  442. #undef wstandend
  443. #define wstandend UNDEF(wstandend)
  444. #endif
  445.  
  446. #ifdef wstandout
  447. inline int UNDEF(wstandout)(WINDOW *win)  { return wstandout(win); }
  448. #undef wstandout
  449. #define wstandout UNDEF(wstandout)
  450. #endif
  451.  
  452.  
  453. #ifdef wattroff
  454. inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); }
  455. #undef wattroff
  456. #define wattroff UNDEF(wattroff)
  457. #endif
  458.  
  459. #ifdef chgat
  460. inline int UNDEF(chgat)(int n, attr_t attr, short color, const void *opts) {
  461.   return chgat(n, attr, color, opts); }
  462. #undef chgat
  463. #define chgat UNDEF(chgat)
  464. #endif
  465.  
  466. #ifdef mvchgat
  467. inline int UNDEF(mvchgat)(int y, int x, int n,
  468.               attr_t attr, short color, const void *opts) {
  469.   return mvchgat(y, x, n, attr, color, opts); }
  470. #undef mvchgat
  471. #define mvchgat UNDEF(mvchgat)
  472. #endif
  473.  
  474. #ifdef mvwchgat
  475. inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n,
  476.                attr_t attr, short color, const void *opts) {
  477.   return mvwchgat(win, y, x, n, attr, color, opts); }
  478. #undef mvwchgat
  479. #define mvwchgat UNDEF(mvwchgat)
  480. #endif
  481.  
  482. #ifdef wattrset
  483. inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); }
  484. #undef wattrset
  485. #define wattrset UNDEF(wattrset)
  486. #endif
  487.  
  488. #ifdef winch
  489. inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); }
  490. #undef winch
  491. #define winch UNDEF(winch)
  492. #endif
  493.  
  494. #ifdef mvwaddch
  495. inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch)
  496. { return mvwaddch(win, y, x, ch); }
  497. #undef mvwaddch
  498. #define mvwaddch UNDEF(mvwaddch)
  499. #endif
  500.  
  501. #ifdef mvwaddchnstr
  502. inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, chtype *str, int n)
  503. { return mvwaddchnstr(win, y, x, str, n); }
  504. #undef mvwaddchnstr
  505. #define mvwaddchnstr UNDEF(mvwaddchnstr)
  506. #endif
  507.  
  508. #ifdef mvwaddchstr
  509. inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, chtype *str)
  510. { return mvwaddchstr(win, y, x, str); }
  511. #undef mvwaddchstr
  512. #define mvwaddchstr UNDEF(mvwaddchstr)
  513. #endif
  514.  
  515. #ifdef addnstr
  516. inline int UNDEF(addnstr)(const char *str, int n)
  517. { return addnstr(str, n); }
  518. #undef addnstr
  519. #define addnstr UNDEF(addnstr)
  520. #endif
  521.  
  522. #ifdef mvwaddnstr
  523. inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n)
  524. { return mvwaddnstr(win, y, x, str, n); }
  525. #undef mvwaddnstr
  526. #define mvwaddnstr UNDEF(mvwaddnstr)
  527. #endif
  528.  
  529. #ifdef mvwaddstr
  530. inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str)
  531. { return mvwaddstr(win, y, x, str); }
  532. #undef mvwaddstr
  533. #define mvwaddstr UNDEF(mvwaddstr)
  534. #endif
  535.  
  536. #ifdef mvwdelch
  537. inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x)
  538. { return mvwdelch(win, y, x); }
  539. #undef mvwdelch
  540. #define mvwdelch UNDEF(mvwdelch)
  541. #endif
  542.  
  543. #ifdef mvwgetch
  544. inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);}
  545. #undef mvwgetch
  546. #define mvwgetch UNDEF(mvwgetch)
  547. #endif
  548.  
  549. #ifdef mvwgetstr
  550. inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str)
  551. {return mvwgetstr(win, y, x, str);}
  552. #undef mvwgetstr
  553. #define mvwgetstr UNDEF(mvwgetstr)
  554. #endif
  555.  
  556. #ifdef mvwgetnstr
  557. inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n)
  558. {return mvwgetnstr(win, y, x, str, n);}
  559. #undef mvwgetnstr
  560. #define mvwgetnstr UNDEF(mvwgetnstr)
  561. #endif
  562.  
  563. #ifdef mvwinch
  564. inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
  565.   return mvwinch(win, y, x);}
  566. #undef mvwinch
  567. #define mvwinch UNDEF(mvwinch)
  568. #endif
  569.  
  570. #ifdef mvwinsch
  571. inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c)
  572. { return mvwinsch(win, y, x, c); }
  573. #undef mvwinsch
  574. #define mvwinsch UNDEF(mvwinsch)
  575. #endif
  576.  
  577. #ifdef mvaddch
  578. inline int UNDEF(mvaddch)(int y, int x, chtype ch)
  579. { return mvaddch(y, x, ch); }
  580. #undef mvaddch
  581. #define mvaddch UNDEF(mvaddch)
  582. #endif
  583.  
  584. #ifdef mvaddnstr
  585. inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n)
  586. { return mvaddnstr(y, x, str, n); }
  587. #undef mvaddnstr
  588. #define mvaddnstr UNDEF(mvaddnstr)
  589. #endif
  590.  
  591. #ifdef mvaddstr
  592. inline int UNDEF(mvaddstr)(int y, int x, const char * str)
  593. { return mvaddstr(y, x, str); }
  594. #undef mvaddstr
  595. #define mvaddstr UNDEF(mvaddstr)
  596. #endif
  597.  
  598. #ifdef mvdelch
  599. inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);}
  600. #undef mvdelch
  601. #define mvdelch UNDEF(mvdelch)
  602. #endif
  603.  
  604. #ifdef mvgetch
  605. inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);}
  606. #undef mvgetch
  607. #define mvgetch UNDEF(mvgetch)
  608. #endif
  609.  
  610. #ifdef mvgetstr
  611. inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);}
  612. #undef mvgetstr
  613. #define mvgetstr UNDEF(mvgetstr)
  614. #endif
  615.  
  616. #ifdef mvgetnstr
  617. inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) {
  618.   return mvgetnstr(y, x, str, n);}
  619. #undef mvgetnstr
  620. #define mvgetnstr UNDEF(mvgetnstr)
  621. #endif
  622.  
  623. #ifdef mvinch
  624. inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}
  625. #undef mvinch
  626. #define mvinch UNDEF(mvinch)
  627. #endif
  628.  
  629. #ifdef mvinsch
  630. inline int UNDEF(mvinsch)(int y, int x, chtype c)
  631. { return mvinsch(y, x, c); }
  632. #undef mvinsch
  633. #define mvinsch UNDEF(mvinsch)
  634. #endif
  635.  
  636. #ifdef napms
  637. inline void UNDEF(napms)(unsigned long x) { napms(x); }
  638. #undef napms
  639. #define napms UNDEF(napms)
  640. #endif
  641.  
  642. #ifdef fixterm
  643. inline int UNDEF(fixterm)(void) { return fixterm(); }
  644. #undef fixterm
  645. #define fixterm UNDEF(fixterm)
  646. #endif
  647.  
  648. #ifdef resetterm
  649. inline int UNDEF(resetterm)(void) { return resetterm(); }
  650. #undef resetterm
  651. #define resetterm UNDEF(resetterm)
  652. #endif
  653.  
  654. #ifdef saveterm
  655. inline int UNDEF(saveterm)(void) { return saveterm(); }
  656. #undef saveterm
  657. #define saveterm UNDEF(saveterm)
  658. #endif
  659.  
  660. #ifdef crmode
  661. inline int UNDEF(crmode)(void) { return crmode(); }
  662. #undef crmode
  663. #define crmode UNDEF(crmode)
  664. #endif
  665.  
  666. #ifdef nocrmode
  667. inline int UNDEF(nocrmode)(void) { return nocrmode(); }
  668. #undef nocrmode
  669. #define nocrmode UNDEF(nocrmode)
  670. #endif
  671.  
  672. #ifdef getbkgd
  673. inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); }
  674. #undef getbkgd
  675. #define getbkgd UNDEF(getbkgd)
  676. #endif
  677.  
  678. #ifdef bkgd
  679. inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); }
  680. #undef bkgd
  681. #define bkgd UNDEF(bkgd)
  682. #endif
  683.  
  684. #ifdef bkgdset
  685. inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }
  686. #undef bkgdset
  687. #define bkgdset UNDEF(bkgdset)
  688. #endif
  689.  
  690. /*
  691.  *
  692.  * C++ class for windows.
  693.  *
  694.  */
  695.  
  696. extern "C" int     _nc_ripoffline(int, int (*init)(WINDOW*, int));
  697. extern "C" int     _nc_xx_ripoff_init(WINDOW *, int);
  698. extern "C" int     _nc_has_mouse(void);
  699.  
  700. class NCURSES_IMPEXP NCursesWindow
  701. {
  702.   friend class NCursesMenu;
  703.   friend class NCursesForm;
  704.  
  705. private:
  706.   static bool    b_initialized;
  707.   static void    initialize();
  708.   friend int     _nc_xx_ripoff_init(WINDOW *, int);
  709.  
  710.   void           init();
  711.  
  712.   short          getcolor(int getback) const;
  713.  
  714.   static int     setpalette(short fore, short back, short pair);
  715.   static int     colorInitialized;
  716.  
  717.   // This private constructor is only used during the initialization
  718.   // of windows generated by ripoffline() calls.
  719.   NCursesWindow(WINDOW* win, int ncols);
  720.  
  721. protected:
  722.   virtual void   err_handler(const char *) const THROWS(NCursesException);
  723.   // Signal an error with the given message text.
  724.  
  725.   static long count;        // count of all active windows:
  726.   //   We rely on the c++ promise that
  727.   //   all otherwise uninitialized
  728.   //   static class vars are set to 0
  729.  
  730.   WINDOW*        w;                // the curses WINDOW
  731.  
  732.   bool           alloced;          // TRUE if we own the WINDOW
  733.  
  734.   NCursesWindow* par;              // parent, if subwindow
  735.   NCursesWindow* subwins;          // head of subwindows list
  736.   NCursesWindow* sib;              // next subwindow of parent
  737.  
  738.   void           kill_subwindows(); // disable all subwindows
  739.   // Destroy all subwindows.
  740.  
  741.   /* Only for use by derived classes. They are then in charge to
  742.      fill the member variables correctly. */
  743.   NCursesWindow();
  744.  
  745. public:
  746.   NCursesWindow(WINDOW* &window);  // useful only for stdscr
  747.  
  748.   NCursesWindow(int nlines,        // number of lines
  749.         int ncols,         // number of columns
  750.         int begin_y,       // line origin
  751.         int begin_x);      // col origin
  752.  
  753.   NCursesWindow(NCursesWindow& par,// parent window
  754.         int nlines,        // number of lines
  755.         int ncols,         // number of columns
  756.         int begin_y,       // absolute or relative
  757.         int begin_x,       //   origins:
  758.         char absrel = 'a');// if `a', begin_y & begin_x are
  759.   // absolute screen pos, else if `r', they are relative to par origin
  760.  
  761.   NCursesWindow(NCursesWindow& par,// parent window
  762.         bool do_box = TRUE);
  763.   // this is the very common case that we want to create the subwindow that
  764.   // is two lines and two columns smaller and begins at (1,1).
  765.   // We may automatically request the box around it.
  766.  
  767.   NCursesWindow& operator=(const NCursesWindow& rhs)
  768.   {
  769.     if (this != &rhs)
  770.       *this = rhs;
  771.     return *this;
  772.   }
  773.  
  774.   NCursesWindow(const NCursesWindow& rhs)
  775.     : w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib)
  776.   {
  777.   }
  778.  
  779.   virtual ~NCursesWindow();
  780.  
  781.   NCursesWindow Clone();
  782.   // Make an exact copy of the window.
  783.  
  784.   // Initialization.
  785.   static void    useColors(void);
  786.   // Call this routine very early if you want to have colors.
  787.  
  788.   static int ripoffline(int ripoff_lines,
  789.             int (*init)(NCursesWindow& win));
  790.   // This function is used to generate a window of ripped-of lines.
  791.   // If the argument is positive, lines are removed from the top, if it
  792.   // is negative lines are removed from the bottom. This enhances the
  793.   // lowlevel ripoffline() function because it uses the internal
  794.   // implementation that allows to remove more than just a single line.
  795.   // This function must be called before any other ncurses function. The
  796.   // creation of the window is deferred until ncurses gets initialized.
  797.   // The initialization function is then called.
  798.  
  799.   // -------------------------------------------------------------------------
  800.   // terminal status
  801.   // -------------------------------------------------------------------------
  802.   int            lines() const { initialize(); return LINES; }
  803.   // Number of lines on terminal, *not* window
  804.  
  805.   int            cols() const { initialize(); return COLS; }
  806.   // Number of cols  on terminal, *not* window
  807.  
  808.   int            tabsize() const { initialize(); return TABSIZE; }
  809.   // Size of a tab on terminal, *not* window
  810.  
  811.   static int     NumberOfColors();
  812.   // Number of available colors
  813.  
  814.   int            colors() const { return NumberOfColors(); }
  815.   // Number of available colors
  816.  
  817.   // -------------------------------------------------------------------------
  818.   // window status
  819.   // -------------------------------------------------------------------------
  820.   int            height() const { return maxy() + 1; }
  821.   // Number of lines in this window
  822.  
  823.   int            width() const { return maxx() + 1; }
  824.   // Number of columns in this window
  825.  
  826.   int            begx() const { return w->_begx; }
  827.   // Column of top left corner relative to stdscr
  828.  
  829.   int            begy() const { return w->_begy; }
  830.   // Line of top left corner relative to stdscr
  831.  
  832.   int            maxx() const { return w->_maxx; }
  833.   // Largest x coord in window
  834.  
  835.   int            maxy() const { return w->_maxy; }
  836.   // Largest y coord in window
  837.  
  838.   short          getcolor() const;
  839.   // Actual color pair
  840.  
  841.   short          foreground() const { return getcolor(0); }
  842.   // Actual foreground color
  843.  
  844.   short          background() const { return getcolor(1); }
  845.   // Actual background color
  846.  
  847.   int            setpalette(short fore, short back);
  848.   // Set color palette entry
  849.  
  850.   int            setcolor(short pair);
  851.   // Set actually used palette entry
  852.  
  853.   // -------------------------------------------------------------------------
  854.   // window positioning
  855.   // -------------------------------------------------------------------------
  856.   virtual int    mvwin(int begin_y, int begin_x) {
  857.     return ::mvwin(w, begin_y, begin_x); }
  858.   // Move window to new position with the new position as top left corner.
  859.   // This is virtual because it is redefined in NCursesPanel.
  860.  
  861.   // -------------------------------------------------------------------------
  862.   // coordinate positioning
  863.   // -------------------------------------------------------------------------
  864.   int            move(int y, int x) { return ::wmove(w, y, x); }
  865.   // Move cursor the this position
  866.  
  867.   void           getyx(int& y, int& x) const { ::getyx(w, y, x); }
  868.   // Get current position of the cursor
  869.  
  870.   int            mvcur(int oldrow, int oldcol, int newrow, int newcol) const {
  871.     return ::mvcur(oldrow, oldcol, newrow, newcol); }
  872.   // Perform lowlevel cursor motion that takes effect immediately.
  873.  
  874.   // -------------------------------------------------------------------------
  875.   // input
  876.   // -------------------------------------------------------------------------
  877.   int            getch() { return ::wgetch(w); }
  878.   // Get a keystroke from the window.
  879.  
  880.   int            getch(int y, int x) { return ::mvwgetch(w, y, x); }
  881.   // Move cursor to position and get a keystroke from the window
  882.  
  883.   int            getstr(char* str, int n=-1) {
  884.     return ::wgetnstr(w, str, n); }
  885.   // Read a series of characters into str until a newline or carriage return
  886.   // is received. Read at most n characters. If n is negative, the limit is
  887.   // ignored.
  888.  
  889.   int            getstr(int y, int x, char* str, int n=-1) {
  890.     return ::mvwgetnstr(w, y, x, str, n); }
  891.   // Move the cursor to the requested position and then perform the getstr()
  892.   // as described above.
  893.  
  894.   int            instr(char *s, int n=-1) { return ::winnstr(w, s, n); }
  895.   // Get a string of characters from the window into the buffer s. Retrieve
  896.   // at most n characters, if n is negative retrieve all characters up to the
  897.   // end of the current line. Attributes are stripped from the characters.
  898.  
  899.   int            instr(int y, int x, char *s, int n=-1) {
  900.     return ::mvwinnstr(w, y, x, s, n); }
  901.   // Move the cursor to the requested position and then perform the instr()
  902.   // as described above.
  903.  
  904.   int            scanw(const char* fmt, ...)
  905.     // Perform a scanw function from the window.
  906. #if __GNUG__ >= 2
  907.     __attribute__ ((format (scanf, 2, 3)));
  908. #else
  909.   ;
  910. #endif
  911.  
  912.   int            scanw(int y, int x, const char* fmt, ...)
  913.     // Move the cursor to the requested position and then perform a scanw
  914.     // from the window.
  915. #if __GNUG__ >= 2
  916.     __attribute__ ((format (scanf, 4, 5)));
  917. #else
  918.   ;
  919. #endif
  920.  
  921.   // -------------------------------------------------------------------------
  922.   // output
  923.   // -------------------------------------------------------------------------
  924.   int            addch(const chtype ch) { return ::waddch(w, ch); }
  925.   // Put attributed character to the window.
  926.  
  927.   int            addch(int y, int x, const chtype ch) {
  928.     return ::mvwaddch(w, y, x, ch); }
  929.   // Move cursor to the requested position and then put attributed character
  930.   // to the window.
  931.  
  932.   int            echochar(const chtype ch) { return ::wechochar(w, ch); }
  933.   // Put attributed character to the window and refresh it immediately.
  934.  
  935.   int            addstr(const char* str, int n=-1) {
  936.     return ::waddnstr(w, str, n); }
  937.   // Write the string str to the window, stop writing if the terminating
  938.   // NUL or the limit n is reached. If n is negative, it is ignored.
  939.  
  940.   int            addstr(int y, int x, const char * str, int n=-1) {
  941.     return ::mvwaddnstr(w, y, x, str, n); }
  942.   // Move the cursor to the requested position and then perform the addstr
  943.   // as described above.
  944.  
  945.   int            printw(const char* fmt, ...)
  946.     // Do a formatted print to the window.
  947. #if (__GNUG__ >= 2) && !defined(printf)
  948.     __attribute__ ((format (printf, 2, 3)));
  949. #else
  950.   ;
  951. #endif
  952.  
  953.   int            printw(int y, int x, const char * fmt, ...)
  954.     // Move the cursor and then do a formatted print to the window.
  955. #if (__GNUG__ >= 2) && !defined(printf)
  956.     __attribute__ ((format (printf, 4, 5)));
  957. #else
  958.   ;
  959. #endif
  960.  
  961.   chtype         inch() const { return ::winch(w); }
  962.   // Retrieve attributed character under the current cursor position.
  963.  
  964.   chtype         inch(int y, int x) { return ::mvwinch(w, y, x); }
  965.   // Move cursor to requested position and then retrieve attributed character
  966.   // at this position.
  967.  
  968.   int            insch(chtype ch) { return ::winsch(w, ch); }
  969.   // Insert attributed character into the window before current cursor
  970.   // position.
  971.  
  972.   int            insch(int y, int x, chtype ch) {
  973.     return ::mvwinsch(w, y, x, ch); }
  974.   // Move cursor to requested position and then insert the attributed
  975.   // character before that position.
  976.  
  977.   int            insertln() { return ::winsdelln(w, 1); }
  978.   // Insert an empty line above the current line.
  979.  
  980.   int            insdelln(int n=1) { return ::winsdelln(w, n); }
  981.   // If n>0 insert that many lines above the current line. If n<0 delete
  982.   // that many lines beginning with the current line.
  983.  
  984.   int            insstr(const char *s, int n=-1) {
  985.     return ::winsnstr(w, s, n); }
  986.   // Insert the string into the window before the current cursor position.
  987.   // Insert stops at end of string or when the limit n is reached. If n is
  988.   // negative, it is ignored.
  989.  
  990.   int            insstr(int y, int x, const char *s, int n=-1) {
  991.     return ::mvwinsnstr(w, y, x, s, n); }
  992.   // Move the cursor to the requested position and then perform the insstr()
  993.   // as described above.
  994.  
  995.   int            attron (chtype at) { return ::wattron (w, at); }
  996.   // Switch on the window attributes;
  997.  
  998.   int            attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); }
  999.   // Switch off the window attributes;
  1000.  
  1001.   int            attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); }
  1002.   // Set the window attributes;
  1003.  
  1004.   int            color_set(short color_pair_number, void* opts=NULL) {
  1005.     return ::wcolor_set(w, color_pair_number, opts); }
  1006.   // Set the window color attribute;
  1007.  
  1008.   int            chgat(int n, attr_t attr, short color, const void *opts=NULL) {
  1009.     return ::wchgat(w, n, attr, color, opts); }
  1010.   // Change the attributes of the next n characters in the current line. If
  1011.   // n is negative or greater than the number of remaining characters in the
  1012.   // line, the attributes will be changed up to the end of the line.
  1013.  
  1014.   int            chgat(int y, int x,
  1015.                int n, attr_t attr, short color, const void *opts=NULL) {
  1016.     return ::mvwchgat(w, y, x, n, attr, color, opts); }
  1017.   // Move the cursor to the requested position and then perform chgat() as
  1018.   // described above.
  1019.  
  1020.   // -------------------------------------------------------------------------
  1021.   // background
  1022.   // -------------------------------------------------------------------------
  1023.   chtype         getbkgd() const { return ::getbkgd(w); }
  1024.   // Get current background setting.
  1025.  
  1026.   int            bkgd(const chtype ch) { return ::wbkgd(w, ch); }
  1027.   // Set the background property and apply it to the window.
  1028.  
  1029.   void           bkgdset(chtype ch) { ::wbkgdset(w, ch); }
  1030.   // Set the background property.
  1031.  
  1032.   // -------------------------------------------------------------------------
  1033.   // borders
  1034.   // -------------------------------------------------------------------------
  1035.   int            box(chtype vert=0, chtype  hor=0) {
  1036.     return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); }
  1037.   // Draw a box around the window with the given vertical and horizontal
  1038.   // drawing characters. If you specify a zero as character, curses will try
  1039.   // to find a "nice" character.
  1040.  
  1041.   int            border(chtype left=0, chtype right=0,
  1042.             chtype top =0, chtype bottom=0,
  1043.             chtype top_left =0, chtype top_right=0,
  1044.             chtype bottom_left =0, chtype bottom_right=0) {
  1045.     return ::wborder(w, left, right, top, bottom, top_left, top_right,
  1046.              bottom_left, bottom_right); }
  1047.   // Draw a border around the window with the given characters for the
  1048.   // various parts of the border. If you pass zero for a character, curses
  1049.   // will try to find "nice" characters.
  1050.  
  1051.   // -------------------------------------------------------------------------
  1052.   // lines and boxes
  1053.   // -------------------------------------------------------------------------
  1054.   int            hline(int len, chtype ch=0) { return ::whline(w, ch, len); }
  1055.   // Draw a horizontal line of len characters with the given character. If
  1056.   // you pass zero for the character, curses will try to find a "nice" one.
  1057.  
  1058.   int            hline(int y, int x, int len, chtype ch=0) {
  1059.     return ::mvwhline(w, y, x, ch, len); }
  1060.   // Move the cursor to the requested position and then draw a horizontal line.
  1061.  
  1062.   int            vline(int len, chtype ch=0) { return ::wvline(w, ch, len); }
  1063.   // Draw a vertical line of len characters with the given character. If
  1064.   // you pass zero for the character, curses will try to find a "nice" one.
  1065.  
  1066.   int            vline(int y, int x, int len, chtype ch=0) {
  1067.     return ::mvwvline(w, y, x, ch, len); }
  1068.   // Move the cursor to the requested position and then draw a vertical line.
  1069.  
  1070.   // -------------------------------------------------------------------------
  1071.   // erasure
  1072.   // -------------------------------------------------------------------------
  1073.   int            erase() { return ::werase(w); }
  1074.   // Erase the window.
  1075.  
  1076.   int            clear() { return ::wclear(w); }
  1077.   // Clear the window.
  1078.  
  1079.   int            clearok(bool bf) { return ::clearok(w, bf); }
  1080.   // Set/Reset the clear flag. If set, the next refresh() will clear the
  1081.   // screen.
  1082.  
  1083.   int            clrtobot() { return ::wclrtobot(w); }
  1084.   // Clear to the end of the window.
  1085.  
  1086.   int            clrtoeol() { return ::wclrtoeol(w); }
  1087.   // Clear to the end of the line.
  1088.  
  1089.   int            delch() { return ::wdelch(w); }
  1090.   // Delete character under the cursor.
  1091.  
  1092.   int            delch(int y, int x) { return ::mvwdelch(w, y, x); }
  1093.   // Move cursor to requested position and delete the character under the
  1094.   // cursor.
  1095.  
  1096.   int            deleteln() { return ::winsdelln(w, -1); }
  1097.   // Delete the current line.
  1098.  
  1099.   // -------------------------------------------------------------------------
  1100.   // screen control
  1101.   // -------------------------------------------------------------------------
  1102.   int            scroll(int amount=1) { return ::wscrl(w, amount); }
  1103.   // Scroll amount lines. If amount is positive, scroll up, otherwise
  1104.   // scroll down.
  1105.  
  1106.   int            scrollok(bool bf) { return ::scrollok(w, bf); }
  1107.   // If bf is TRUE, window scrolls if cursor is moved off the bottom
  1108.   // edge of the window or a scrolling region, otherwise the cursor is left
  1109.   // at the bottom line.
  1110.  
  1111.   int            setscrreg(int from, int to) {
  1112.     return ::wsetscrreg(w, from, to); }
  1113.   // Define a soft scrolling region.
  1114.  
  1115.   int            idlok(bool bf) { return ::idlok(w, bf); }
  1116.   // If bf is TRUE, use insert/delete line hardware support if possible.
  1117.   // Otherwise do it in software.
  1118.  
  1119.  
  1120.   void           idcok(bool bf) { ::idcok(w, bf); }
  1121.   // If bf is TRUE, use insert/delete character hardware support if possible.
  1122.   // Otherwise do it in software.
  1123.  
  1124.   int            touchwin()   { return ::wtouchln(w, 0, height(), 1); }
  1125.   // Mark the whole window as modified.
  1126.  
  1127.   int            untouchwin() { return ::wtouchln(w, 0, height(), 0); }
  1128.   // Mark the whole window as unmodified.
  1129.  
  1130.   int            touchln(int s, int cnt, bool changed=TRUE) {
  1131.     return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
  1132.   // Mark cnt lines beginning from line s as changed or unchanged, depending
  1133.   // on the value of the changed flag.
  1134.  
  1135.   bool           is_linetouched(int line) const {
  1136.     return (::is_linetouched(w, line) ? TRUE:FALSE); }
  1137.   // Return TRUE if line is marked as changed, FALSE otherwise
  1138.  
  1139.   bool           is_wintouched() const {
  1140.     return (::is_wintouched(w) ? TRUE:FALSE); }
  1141.   // Return TRUE if window is marked as changed, FALSE otherwise
  1142.  
  1143.   int            leaveok(bool bf) { return ::leaveok(w, bf); }
  1144.   // If bf is TRUE, curses will leave the cursor after an update whereever
  1145.   // it is after the update.
  1146.  
  1147.   int            redrawln(int from, int n) { return ::wredrawln(w, from, n); }
  1148.   // Redraw n lines starting from the requested line
  1149.  
  1150.   int            redrawwin() { return ::wredrawln(w, 0, height()); }
  1151.   // Redraw the whole window
  1152.  
  1153.   int            doupdate()  { return ::doupdate(); }
  1154.   // Do all outputs to make the physical screen looking like the virtual one
  1155.  
  1156.   void           syncdown()  { ::wsyncdown(w); }
  1157.   // Propagate the changes down to all descendant windows
  1158.  
  1159.   void           syncup()    { ::wsyncup(w); }
  1160.   // Propagate the changes up in the hierarchy
  1161.  
  1162.   void           cursyncup() { ::wcursyncup(w); }
  1163.   // Position the cursor in all ancestor windows corresponding to our setting
  1164.  
  1165.   int            syncok(bool bf) { return ::syncok(w, bf); }
  1166.   // If called with bf=TRUE, syncup() is called whenever the window is changed
  1167.  
  1168. #ifndef _no_flushok
  1169.   int            flushok(bool bf) { return ::flushok(w, bf); }
  1170. #endif
  1171.  
  1172.   void           immedok(bool bf) { ::immedok(w, bf); }
  1173.   // If called with bf=TRUE, any change in the window will cause an
  1174.   // automatic immediate refresh()
  1175.  
  1176.   int            keypad(bool bf) { return ::keypad(w, bf); }
  1177.   // If called with bf=TRUE, the application will interpret function keys.
  1178.  
  1179.   int            meta(bool bf) { return ::meta(w, bf); }
  1180.   // If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise
  1181.   // 7-Bit characters are generated.
  1182.  
  1183.   int            standout() { return ::wstandout(w); }
  1184.   // Enable "standout" attributes
  1185.  
  1186.   int            standend() { return ::wstandend(w); }
  1187.   // Disable "standout" attributes
  1188.  
  1189.   // -------------------------------------------------------------------------
  1190.   // The next two are virtual, because we redefine them in the
  1191.   // NCursesPanel class.
  1192.   // -------------------------------------------------------------------------
  1193.   virtual int    refresh() { return ::wrefresh(w); }
  1194.   // Propagate the changes in this window to the virtual screen and call
  1195.   // doupdate(). This is redefined in NCursesPanel.
  1196.  
  1197.   virtual int    noutrefresh() { return ::wnoutrefresh(w); }
  1198.   // Propagate the changes in this window to the virtual screen. This is
  1199.   // redefined in NCursesPanel.
  1200.  
  1201.   // -------------------------------------------------------------------------
  1202.   // multiple window control
  1203.   // -------------------------------------------------------------------------
  1204.   int            overlay(NCursesWindow& win) {
  1205.     return ::overlay(w, win.w); }
  1206.   // Overlay this window over win.
  1207.  
  1208.   int            overwrite(NCursesWindow& win) {
  1209.     return ::overwrite(w, win.w); }
  1210.   // Overwrite win with this window.
  1211.  
  1212.   int            copywin(NCursesWindow& win,
  1213.              int sminrow, int smincol,
  1214.              int dminrow, int dmincol,
  1215.              int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
  1216.     return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
  1217.              dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); }
  1218.   // Overlay or overwrite the rectangle in win given by dminrow,dmincol,
  1219.   // dmaxrow,dmaxcol with the rectangle in this window beginning at
  1220.   // sminrow,smincol.
  1221.  
  1222.   // -------------------------------------------------------------------------
  1223.   // Mouse related
  1224.   // -------------------------------------------------------------------------
  1225.   bool has_mouse() const;
  1226.   // Return TRUE if terminal supports a mouse, FALSE otherwise
  1227.  
  1228.   // -------------------------------------------------------------------------
  1229.   // traversal support
  1230.   // -------------------------------------------------------------------------
  1231.   NCursesWindow*  child() { return subwins; }
  1232.   // Get the first child window.
  1233.  
  1234.   NCursesWindow*  sibling() { return sib; }
  1235.   // Get the next child of my parent.
  1236.  
  1237.   NCursesWindow*  parent() { return par; }
  1238.   // Get my parent.
  1239.  
  1240.   bool isDescendant(NCursesWindow& win);
  1241.   // Return TRUE if win is a descendant of this.
  1242. };
  1243.  
  1244. // -------------------------------------------------------------------------
  1245. // We leave this here for compatibility reasons.
  1246. // -------------------------------------------------------------------------
  1247. class NCURSES_IMPEXP NCursesColorWindow : public NCursesWindow
  1248. {
  1249. public:
  1250.   NCursesColorWindow(WINDOW* &window)   // useful only for stdscr
  1251.     : NCursesWindow(window) {
  1252.       useColors(); }
  1253.  
  1254.   NCursesColorWindow(int nlines,        // number of lines
  1255.              int ncols,         // number of columns
  1256.              int begin_y,       // line origin
  1257.              int begin_x)       // col origin
  1258.     : NCursesWindow(nlines, ncols, begin_y, begin_x) {
  1259.       useColors(); }
  1260.  
  1261.   NCursesColorWindow(NCursesWindow& parentWin,// parent window
  1262.              int nlines,        // number of lines
  1263.              int ncols,         // number of columns
  1264.              int begin_y,       // absolute or relative
  1265.              int begin_x,       //   origins:
  1266.              char absrel = 'a') // if `a', by & bx are
  1267.     : NCursesWindow(parentWin,
  1268.             nlines, ncols,    // absolute screen pos,
  1269.             begin_y, begin_x,   // else if `r', they are
  1270.             absrel ) {          // relative to par origin
  1271.       useColors(); }
  1272. };
  1273.  
  1274. // These enum definitions really belong inside the NCursesPad class, but only
  1275. // recent compilers support that feature.
  1276.  
  1277.   typedef enum {
  1278.     REQ_PAD_REFRESH = KEY_MAX + 1,
  1279.     REQ_PAD_UP,
  1280.     REQ_PAD_DOWN,
  1281.     REQ_PAD_LEFT,
  1282.     REQ_PAD_RIGHT,
  1283.     REQ_PAD_EXIT
  1284.   } Pad_Request;
  1285.  
  1286.   const Pad_Request PAD_LOW  = REQ_PAD_REFRESH;   // lowest  op-code
  1287.   const Pad_Request PAD_HIGH = REQ_PAD_EXIT;      // highest op-code
  1288.  
  1289. // -------------------------------------------------------------------------
  1290. // Pad Support. We allow an association of a pad with a "real" window
  1291. // through which the pad may be viewed.
  1292. // -------------------------------------------------------------------------
  1293. class NCURSES_IMPEXP NCursesPad : public NCursesWindow
  1294. {
  1295. private:
  1296.   NCursesWindow* viewWin;       // the "viewport" window
  1297.   NCursesWindow* viewSub;       // the "viewport" subwindow
  1298.  
  1299.   int h_gridsize, v_gridsize;
  1300.  
  1301. protected:
  1302.   int min_row, min_col;         // top left row/col of the pads display area
  1303.  
  1304.   NCursesWindow* Win(void) const {
  1305.     // Get the window into which the pad should be copied (if any)
  1306.     return (viewSub?viewSub:(viewWin?viewWin:0));
  1307.   }
  1308.  
  1309.   NCursesWindow* getWindow(void) const {
  1310.     return viewWin;
  1311.   }
  1312.  
  1313.   NCursesWindow* getSubWindow(void) const {
  1314.     return viewSub;
  1315.   }
  1316.  
  1317.   virtual int driver (int key);      // Virtualize keystroke key
  1318.   // The driver translates the keystroke c into an Pad_Request
  1319.  
  1320.   virtual void OnUnknownOperation(int pad_req) {
  1321.     ::beep();
  1322.   }
  1323.   // This is called if the driver returns an unknown op-code
  1324.  
  1325.   virtual void OnNavigationError(int pad_req) {
  1326.     ::beep();
  1327.   }
  1328.   // This is called if a navigation request couldn't be satisfied
  1329.  
  1330.   virtual void OnOperation(int pad_req) {
  1331.   };
  1332.   // OnOperation is called if a Pad_Operation was executed and just before
  1333.   // the refresh() operation is done.
  1334.  
  1335. public:
  1336.   NCursesPad(int nlines, int ncols);
  1337.   // create a pad with the given size
  1338.  
  1339.   NCursesPad& operator=(const NCursesPad& rhs)
  1340.   {
  1341.     if (this != &rhs) {
  1342.       *this = rhs;
  1343.       NCursesWindow::operator=(rhs);
  1344.     }
  1345.     return *this;
  1346.   }
  1347.  
  1348.   NCursesPad(const NCursesPad& rhs)
  1349.     : NCursesWindow(rhs),
  1350.       viewWin(rhs.viewWin),
  1351.       viewSub(rhs.viewSub),
  1352.       h_gridsize(rhs.h_gridsize),
  1353.       v_gridsize(rhs.v_gridsize),
  1354.       min_row(rhs.min_row),
  1355.       min_col(rhs.min_col)
  1356.   {
  1357.   }
  1358.  
  1359.   virtual ~NCursesPad() {}
  1360.  
  1361.   int echochar(const chtype ch) { return ::pechochar(w, ch); }
  1362.   // Put the attributed character onto the pad and immediately do a
  1363.   // prefresh().
  1364.  
  1365.   int refresh();
  1366.   // If a viewport is defined the pad is displayed in this window, otherwise
  1367.   // this is a noop.
  1368.  
  1369.   int refresh(int pminrow, int pmincol,
  1370.           int sminrow, int smincol,
  1371.           int smaxrow, int smaxcol) {
  1372.     return ::prefresh(w, pminrow, pmincol,
  1373.               sminrow, smincol, smaxrow, smaxcol);
  1374.   }
  1375.   // The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle
  1376.   // on the screen. <b>refresh</b> copies a rectangle of this size beginning
  1377.   // with top left corner pminrow,pmincol onto the screen and calls doupdate().
  1378.  
  1379.   int noutrefresh();
  1380.   // If a viewport is defined the pad is displayed in this window, otherwise
  1381.   // this is a noop.
  1382.  
  1383.   int noutrefresh(int pminrow, int pmincol,
  1384.           int sminrow, int smincol,
  1385.           int smaxrow, int smaxcol) {
  1386.     return ::pnoutrefresh(w, pminrow, pmincol,
  1387.               sminrow, smincol, smaxrow, smaxcol);
  1388.   }
  1389.   // Does the same as refresh() but without calling doupdate().
  1390.  
  1391.   virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1);
  1392.   // Add the window "view" as viewing window to the pad.
  1393.  
  1394.   virtual void setSubWindow(NCursesWindow& sub);
  1395.   // Use the subwindow "sub" of the viewport window for the actual viewing.
  1396.   // The full viewport window is usually used to provide some decorations
  1397.   // like frames, titles etc.
  1398.  
  1399.   virtual void operator() (void);
  1400.   // Perform Pad's operation
  1401. };
  1402.  
  1403. // A FramedPad is constructed always with a viewport window. This viewport
  1404. // will be framed (by a box() command) and the interior of the box is the
  1405. // viewport subwindow. On the frame we display scrollbar sliders.
  1406. class NCURSES_IMPEXP NCursesFramedPad : public NCursesPad
  1407. {
  1408. protected:
  1409.   virtual void OnOperation(int pad_req);
  1410.  
  1411. public:
  1412.   NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
  1413.            int v_grid = 1, int h_grid = 1)
  1414.     : NCursesPad(nlines, ncols) {
  1415.     NCursesPad::setWindow(win, v_grid, h_grid);
  1416.     NCursesPad::setSubWindow(*(new NCursesWindow(win)));
  1417.   }
  1418.   // Construct the FramedPad with the given Window win as viewport.
  1419.  
  1420.   virtual ~NCursesFramedPad() {
  1421.     delete getSubWindow();
  1422.   }
  1423.  
  1424.   void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) {
  1425.     err_handler("Operation not allowed");
  1426.   }
  1427.   // Disable this call; the viewport is already defined
  1428.  
  1429.   void setSubWindow(NCursesWindow& sub) {
  1430.     err_handler("Operation not allowed");
  1431.   }
  1432.   // Disable this call; the viewport subwindow is already defined
  1433.  
  1434. };
  1435.  
  1436. #endif /* NCURSES_CURSESW_H_incl */
  1437.